package com.gc.server.controller.api;

import com.gc.server.entity.GoodsEntity;
import com.gc.server.enums.GoodsStatusEnum;
import com.gc.server.service.GoodsService;
import com.yf.annotation.IgnoreAuth;
import com.yf.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api/goods")
@RestController
public class ApiGoodsController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 获取所有上架的物料
     * @return
     */
    @GetMapping("/list")
    @IgnoreAuth
    public R list(){
     List<GoodsEntity> goodsEntities =  goodsService.findByStatus(GoodsStatusEnum.OPEN.getIndex());
     return R.ok(goodsEntities);
    }

}
